package com.ssy.lingxi.member.merchant.controller.web;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.member.merchant.model.vo.basic.request.UserPageVO;
import com.ssy.lingxi.member.merchant.model.vo.maintenance.request.*;
import com.ssy.lingxi.member.merchant.model.vo.maintenance.response.*;
import com.ssy.lingxi.member.merchant.model.vo.manage.request.MemberManagePageByNameVO;
import com.ssy.lingxi.member.merchant.service.web.IMemberAbilitySalesService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @menu 渠道能力 - 业务员管理相关接口
 * @author 万宁
 * @version 2.0.0
 * @date 2021-04-14
 */
@RestController
@RequestMapping("/member/ability/sales")
public class MemberAbilitySalesController {

    @Resource
    private IMemberAbilitySalesService memberAbilitySalesService;

    /**
     * 分页查询已经绑定渠道的业务员列表
     * @param headers HttpHeader信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberSalesPageQueryVO>> pageMemberSales(@RequestHeader HttpHeaders headers, @Valid MemberSalesPageVO pageVO) {
        return memberAbilitySalesService.pageMemberSales(headers, pageVO);
    }

    /**
     * “选择业务员” - 分页查询业务员列表
     * @param headers HttpHeader信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/select", method = RequestMethod.GET)
    public Wrapper<PageData<MemberSalesSelectQueryVO>> pageSelectMemberSales(@RequestHeader HttpHeaders headers, @Valid UserPageVO pageVO) {
        return memberAbilitySalesService.pageSelectMemberSales(headers, pageVO);
    }

    /**
     * 新增业务员
     * @param headers HttpHeader信息
     * @param idVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Wrapper<MemberSalesGetVO> addMemberSales(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberUserIdVO idVO) {
        return memberAbilitySalesService.addMemberSales(headers, idVO);
    }

    /**
     * 查询业务员基本信息
     * @param headers HttpHeader信息
     * @param idVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/get", method = RequestMethod.GET)
    public Wrapper<MemberSalesGetVO> getMemberSales(@RequestHeader HttpHeaders headers, @Valid MemberUserIdVO idVO) {
        return memberAbilitySalesService.getMemberSales(headers, idVO);
    }

    /**
     * 分页查询渠道会员列表
     * @param headers HttpHeader信息
     * @param pageByNameVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/channel/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberSalesBindChannelQueryVO>> pageChannels(@RequestHeader HttpHeaders headers, @Valid MemberManagePageByNameVO pageByNameVO) {
        return memberAbilitySalesService.pageChannels(headers, pageByNameVO);
    }

    /**
     * 新增业务员，绑定/解绑渠道
     * @param headers HttpHeader信息
     * @param bindChannelVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/channel/bind", method = RequestMethod.POST)
    public Wrapper<Void> bindSalesChannels(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberSalesBindChannelVO bindChannelVO) {
        return memberAbilitySalesService.bindSalesChannels(headers, bindChannelVO);
    }

    /**
     * 解除业务员与渠道的绑定
     * @param headers HttpHeader信息
     * @param unBindChannelVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/channel/unbind", method = RequestMethod.POST)
    public Wrapper<Void> unBindSalesChannel(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberSalesUnBindChannelVO unBindChannelVO) {
        return memberAbilitySalesService.unBindSalesChannel(headers, unBindChannelVO);
    }

    /**
     * 查询业务员信息、分页查询绑定的渠道列表
     * @param headers HttpHeader信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/channel", method = RequestMethod.GET)
    public Wrapper<MemberSalesChannelQueryVO> getSalesAndPageChannels(@RequestHeader HttpHeaders headers, @Valid MemberSalesChannelPageVO pageVO) {
        return memberAbilitySalesService.getSalesAndPageChannels(headers, pageVO);
    }

    /**
     * 删除业务员
     * @param headers HttpHeader信息
     * @param idVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public Wrapper<Void> deleteSales(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberUserIdVO idVO) {
        return memberAbilitySalesService.deleteSales(headers, idVO);
    }
}
